package com.evon.yardmanagement.ui.action;

import java.util.List;

import com.evon.yardmanagement.model.ParkingSlot;
import com.evon.yardmanagement.service.ParkingSlotsService;
import com.evon.yardmanagement.transformer.ParkingSlotTransfer;
import com.evon.yardmanagement.ui.dto.ParkingSlotDTO;
import com.opensymphony.xwork2.ActionSupport;

public class ShowParkingSlotsAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private ParkingSlotDTO availableParkSlots;

	public ParkingSlotDTO getAvailableParkSlots() {
		return availableParkSlots;
	}

	public void setAvailableParkSlots(ParkingSlotDTO availableParkSlots) {
		this.availableParkSlots = availableParkSlots;
	}
	
	public String execute() throws Exception {

		ParkingSlotsService service = new ParkingSlotsService();
		List<ParkingSlot> parkingSlots = service.getAllParkingslSlots();
		if (!parkingSlots.isEmpty()){
		System.out.println("tttttt---"+parkingSlots.get(0).getName());
		availableParkSlots = ParkingSlotTransfer.transformToModel(parkingSlots.get(0));
		}
		
		return SUCCESS;
	}
}
